<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="string" uri="http://jakarta.apache.org/taglibs/string-1.1" %>
<%@ taglib uri="/WEB-INF/tlds/pagination.tld" prefix="pagination" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Bettersoft Portal</title>
    <link href="/common/css/indexStyle.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="/common/js/common.js"></script>
    <script type='text/javascript' src="/common/dwr/engine.js"></script>
    <script type='text/javascript' src="/common/dwr/util.js"></script>
    <script type='text/javascript' src='/dwr/interface/BettersoftPortalService.js'></script>

    <script type="text/javascript">

        dwr.engine.setErrorHandler(handler);

        function handler(error) {
            alert("error: " + error);
        }


        // Locale 설정을 바꾼다.
        function jsChangeLocale(lan) {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "intro";
            TheForm.action = "${pageContext.request.contextPath}/changeLocale.do?language=" + lan;
            TheForm.submit();
        }

        // Notice Board List 페이지로 이동한다.
        function jsNoticeBoardList() {
            var TheForm = document.menuFrm;
            TheForm.title.value = TheForm.search_title.value;
            TheForm.writer_id.value = TheForm.search_writer.value;
            TheForm.writer_nick_name.value = TheForm.search_nickName.value;
            TheForm.content.value = TheForm.search_content.value;
            TheForm.nextTarget.value = "noticeBoardList";	// page name
            TheForm.action = "./noticeBoardList.do";
            TheForm.submit();
        }

        // Community Board List 페이지로 이동한다.
        function jsCommunityBoardList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "communityBoardList";	// page name
            TheForm.action = "./communityBoardList.do";
            TheForm.submit();
        }

        // Member List 페이지로 이동한다.
        function jsMemberList() {
            var TheForm = document.menuFrm;
            TheForm.nextTarget.value = "memberList";	// page name
            TheForm.action = "./memberList.do";
            TheForm.submit();
        }

        //패스워드 확인 작업을 수행하고 비밀번호 변경 페이지로 이동한다.
        function jsPasswordConfirm(){
            var TheForm = document.frm;

            // 비밀번호 미입력
            if(trim(TheForm.PASSWORD.value) == "") {
                alert("비밀번호를 입력하세요.");
                TheForm.PASSWORD.value = "";
                TheForm.PASSWORD.focus();
                return false;
            }else {
                dwr.engine.setAsync(false);

                // 회원의 ID 와 해당 회원의 비밀번호가 일치하는지 검사
                BettersoftPortalService.logIn(TheForm.BETTERSOFT_ID.value, TheForm.PASSWORD.value, function(loginResult) {
                    if(loginResult == "NON_EXIST") {
                        alert("아이디가 존재하지 않습니다.");
                        return false;
                    } else if(loginResult == "FALSE") {
                        alert("비밀번호가 일치하지 않습니다.");
                        TheForm.PASSWORD.value = "";
                        TheForm.PASSWORD.focus();
                        return false;
                    } else {
                        TheForm.nextTarget.value = "passwordChange";
                        TheForm.action = "./passwordChange.do";
                        TheForm.submit();
                    }
                });
                dwr.engine.setAsync(true);
            }
        }


    </script>
</head>
<body>
<!------------------------------ top 시작-------------------------------------->
<%@include file="portalHeader.jsp" %>
<!------------------------------ top 끝-------------------------------------->
<div id="wrap">
    <form name="frm" method="POST" onsubmit="return false;">
        <input type="hidden" name="nextTarget" value="" />
        <input type="hidden" name="BETTERSOFT_ID" value="<%=s.getAttribute("userId")%>" />
        <div>
            비밀번호 확인<br />
            비밀번호 : <input type="password" class="input" name="PASSWORD" size="30" />
            <a href="javascript:jsPasswordConfirm()">확인</a>
            <a href="intro.do" class="btn_text2">취소</a>

        </div>
    </form>
</div>
<!------------------------------ top 시작-------------------------------------->
<%@include file="portalFooter.jsp" %>
<!------------------------------ top 끝-------------------------------------->
</body>
</html>